/**
 * 
 */
package sk.lukaskrupa.guess.the.color.logging;

import java.io.IOException;

import android.util.Log;

/**
 * Provide and encapsulate android logging API.
 * 
 * @author Lukas Krupa (lukas0krupa@gmail.com)
 * 
 */
@SuppressWarnings("rawtypes")
public class Logging {

	public static final String REGULAR_LOG = "Regular log";

	private final Class classToLog;

	/**
	 * Creating logger for given class.
	 * 
	 * @param classToLog
	 *            which class
	 * 
	 */
	private Logging(Class classToLog) {
		this.classToLog = classToLog;
	}

	/**
	 * Creates log for class.
	 * 
	 * @param classToLog
	 *            which is asking for Logger
	 * @return logger instance
	 */
	public static Logging getLog(Class classToLog) {
		return new Logging(classToLog);
	}

	/**
	 * logging with Class name and method tag.
	 * 
	 * @param method
	 *            which logs
	 * @param message
	 *            message to log
	 */
	public void debug(String method, String message) {
		Log.d(this.classToLog.getSimpleName() + "#" + method, message);
	}

	/**
	 * logging with Class name and method tag.
	 * 
	 * @param method
	 *            which logs
	 * @param message
	 *            message to log
	 */
	public void info(String method, String message) {
		Log.i(this.classToLog.getSimpleName() + "#" + method, message);
	}

	/**
	 * logging with Class name and method tag.
	 * 
	 * @param method
	 *            which logs
	 * @param message
	 *            message to log
	 */
	public void warn(String method, String message) {
		Log.w(this.classToLog.getSimpleName() + "#" + method, message);
	}

	/**
	 * Logging error with exception stacktrace.
	 * 
	 * @param method
	 *            which logs
	 * @param message
	 *            to Log
	 * @param exception
	 *            that was thrown
	 */
	public void error(String method, String message, IOException exception) {
		Log.e(this.classToLog.getSimpleName() + "#" + method, message, exception);
	}

	/**
	 * Logging warn with exception stacktrace.
	 * 
	 * @param method
	 *            which logs
	 * @param message
	 *            to Log
	 * @param exception
	 *            that was thrown
	 */
	public void warn(String method, String message, IOException exception) {
		Log.w(this.classToLog.getSimpleName() + "#" + method, message, exception);
	}

	/**
	 * Logging verbose (trace) with exception.
	 * 
	 * @param method
	 *            which logs
	 * @param message
	 *            to log
	 */
	public void trace(String method, String message) {
		Log.v(this.classToLog.getSimpleName() + "#" + method, message);
	}

	/**
	 * Logging verbose (trace) with exception.
	 * 
	 * @param method
	 *            which logs
	 * @param message
	 *            to log
	 * @param exception
	 *            what was thrown
	 */
	public void trace(String method, String message, IOException exception) {
		Log.v(this.classToLog.getSimpleName() + "#" + method, message, exception);
	}

}
